
package com.yzh.pinboard.CameraPreview;

import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.hardware.display.DisplayManagerCompat;
import android.support.v4.view.ViewCompat;
import android.view.Display;
import android.view.View;


public class ViewCompat2 {

    private ViewCompat2() {
    }

    public static Display getDisplay(@NonNull View view) {
        if (Build.VERSION.SDK_INT >= 17) {
            return view.getDisplay();
        }
        return ViewCompat.isAttachedToWindow(view) ?
                DisplayManagerCompat.getInstance(view.getContext())
                        .getDisplay(Display.DEFAULT_DISPLAY) : null;
    }

}
